const {seq, DataTypes} = require('../sequelize')

const MemberAttributes = {
    name: {
        type: DataTypes.STRING,
        allowNull: false,
        Comment: '姓名',
    },
    credential_type: {
        type: DataTypes.STRING,
        select: true,
        allowNull: false,
        Comment: '证件类型',
        unique: 'index_credential_type_no'
    },
    credential_no: {
        type: DataTypes.STRING,
        allowNull: false,
        Comment: '证件号',
        unique: 'index_credential_type_no'
    },
    gender: {
        type: DataTypes.STRING,
        select: true,
        allowNull: false,
        Comment: '性别',
    },
    birthday: {
        type: DataTypes.DATEONLY,
        allowNull: false,
        Comment: '生日',
    },
    job: { /*职位*/
        type: DataTypes.STRING,
        allowNull: false,
        Comment: '职务',
    },
    level: { /*级别*/
        type: DataTypes.STRING,
        select: true,
        allowNull: false,
        Comment: '级别',
    },
    salary: { /*月薪*/
        type: DataTypes.INTEGER,
        allowNull: false,
        Comment: '月薪',
    },
    join_date: { /*入职日期*/
        type: DataTypes.DATEONLY,
        allowNull: false,
        Comment: '入职日期',
    },
    record_user: { /*信息录入人*/
        type: DataTypes.STRING,
        Comment: '录入人',
    },
    update_user: { /*信息修改人*/
        type: DataTypes.STRING,
        Comment: '修改人',
    },
    phone: { 
        type: DataTypes.STRING,
        Comment: '手机号',
    },
    email: { 
        type: DataTypes.STRING,
        Comment: '电子邮箱',
    },
    state: { 
        type: DataTypes.BOOLEAN,
        Comment: '是否在职',
    },
    introduction: { 
        type: DataTypes.TEXT,
        allowNull: true,
        Comment: '简介',
    },
    
}

const Member = seq.define('yyb_member',MemberAttributes, {
    createdAt: true,
    updatedAt: true,
    timestamps: false,
    freezeTableName: true
})

Member.sync() 

module.exports = {
    Member,
    MemberAttributes
} 
